<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.28.11/sweetalert2.all.js"></script>
<link href="https://cdn.bootcss.com/limonte-sweetalert2/7.28.11/sweetalert2.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
<title>分公司加盟</title>

<style type="text/css">
	.center{text-align: center;}
	.login-page {
	  width: 492px;
	  padding: 8% 0 0;
	  margin: auto;
	}
	.form {
	  position: relative;
	  z-index: 1;
	  background: #FFFFFF;
	  margin: 0 auto 100px;
	  height: 242px;
	  padding: 45px;
	  text-align: center;
	  height:600px;
	}
	.form input {
	  font-family: "Roboto", sans-serif;
	  outline: 0;
	  background: #f2f2f2;
	  width: 100%;
	  border: 0;
	  margin: 0 0 15px;
	  padding: 15px;
	  box-sizing: border-box;
	  font-size: 14px;
	}
	.form textarea {
	  min-width:207px;
	  max-width:442px;
	  max-height:155px;
	  font-family: "Roboto", sans-serif;
	  outline: 0;
	  background: #f2f2f2;
	  width: 100%;
	  border: 0;
	  margin: 0 0 15px;
	  padding: 15px;
	  box-sizing: border-box;
	  font-size: 14px;
	}
	#login {
	  font-family: "Microsoft YaHei","Roboto", sans-serif;
	  text-transform: uppercase;
	  outline: 0;
	  background: #4CAF50;
	  width: 50%;
	  border: 0;
	  padding: 15px;
	  color: #FFFFFF;
	  font-size: 14px;
	  -webkit-transition: all 0.3 ease;
	  transition: all 0.3 ease;
	  cursor: pointer;
	}
	.form button:hover,.form button:active,.form button:focus {
	  background: #43A047;
	}
	.form .message {
	  margin: 15px 0 0;
	  color: #b3b3b3;
	  font-size: 12px;
	}
	.form .message a {
	  color: #4CAF50;
	  text-decoration: none;
	}
	.form .register-form {
	  display: none;
	}
	.container {
	  position: relative;
	  z-index: 1;
	  max-width: 300px;
	  margin: 0 auto;
	}
	.container:before, .container:after {
	  content: "";
	  display: block;
	  clear: both;
	}
	.container .info {
	  margin: 50px auto;
	  text-align: center;
	}
	.container .info h1 {
	  margin: 0 0 15px;
	  padding: 0;
	  font-size: 36px;
	  font-weight: 300;
	  color: #1a1a1a;
	}
	.container .info span {
	  color: #4d4d4d;
	  font-size: 12px;
	}
	.container .info span a {
	  color: #000000;
	  text-decoration: none;
	}
	.container .info span .fa {
	  color: #EF3B3A;
	}
	body {
	  background: #76b852; /* fallback for old browsers */
	  background: -webkit-linear-gradient(right, #76b852, #8DC26F);
	  background: -moz-linear-gradient(right, #76b852, #8DC26F);
	  background: -o-linear-gradient(right, #76b852, #8DC26F);
	  background: linear-gradient(to left, #76b852, #8DC26F);
	  font-family: "Roboto", sans-serif;
	  -webkit-font-smoothing: antialiased;
	  -moz-osx-font-smoothing: grayscale;      
	}
	
	

	
	p.center{
		color: #fff;font-family: "Microsoft YaHei";
	}
	span{
	font-family: "Roboto", sans-serif;
    font-size: 14px;
    color:red;
	}
	
</style>

</head>
<body>
<div class="htmleaf-container">
	<p class="center">分公司加盟</p>
	<div id="wrapper" class="login-page">
	  <div id="login_form" class="form">
	  	<form id="loginFrom" method="post" class="login-form">
		  <input type="text" name="buName" placeholder="请输入用户名" id="buName" maxlength="15"/>
		   <span id="buName_notice"></span>
		  <input type="password" name="buPwd" placeholder="请输入密码" id="buPwd" maxlength="15"/>
		   <span id="buPwd_notice"></span>
		   <input type="text" name="buPhone" placeholder="请输入联系电话" id="buPhone" maxlength="12"/>
		   <span id="buPhone_notice"></span>
		  <input type="text" name="companyName" placeholder="请输入公司名" id="companyName" maxlength="15"/>
		   <span id="companyName_notice"></span>
		  <textarea name="companyAddress" placeholder="请输入公司地址" id="companyAddress" maxlength="50" ></textarea>
		   <p><span id="companyAddress_notice" class="spanA"></span></p>
		  <input type="button" id="login" value="提交"/>
		</form>
		
	  </div>
	</div>
</div>

<script src="https://lib.baomitu.com/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript">

function check_login(){
		
	 	var data=$("#loginFrom").serialize();
		var url="../../listenCompany/addLeague.action";
		$.post(url,data,function(mes){
			if(mes.state==1){
				swal({
				    title: mes.msg,
				    
			 	    allowOutsideClick:false
				}).then(
				    function () {
				    	location.href="../../login.html";
				    }
				    
				) 
						
			}else{
				swal({
				    title: '提交失败',
				    type: 'error',
				    width:'300px',
				    allowOutsideClick:false
				})
				
			}
		},"json")
	}

function check_register(){
	
	var s=document.getElementsByName("dui");
	
	if(s.length==5){
		check_login();
		
	}else{
		swal({
		    title: '提交失败',
		    type: 'error',
		   
		    allowOutsideClick:false
		})
		/* cleanText(); */
		 
	}
	
}
$(function(){
	$("#companyName").blur(function(){
		var str=/^[\u4e00-\u9fa5a-z]+$/gi;
		var userval=$("#companyName").val();
		if(userval==""){
			$("#companyName_notice").html("<font color='#FF0000'>不能为空</font>");
		}else if(!str.test(userval)){
			$("#companyName_notice").html("<font >不能输入特殊符号</font>");
		}else{
			var url="../../listenCompany/findByCompanyName.action";
			var data={"companyName":userval};
			$.post(url,data,function(mes){
				if(mes.datas==0){
					$("#companyName_notice").html("<font color='#FF0000'>"+mes.msg+"</font>");
				}else{
					$("#companyName_notice").html("<font  name='dui'></font>");
				}
			},"json")
		}
		
	})
	$("#buName").blur(function(){
		var userval=$("#buName").val();
		if(userval==""){
			$("#buName_notice").html("<font color='#FF0000'>不能为空</font>");
		}else{
			var url="../../listenBackstageUser/findByBuName.action";
			var data={"buName":userval};
			$.post(url,data,function(mes){
				if(mes.datas==0){
					$("#buName_notice").html("<font color='#FF0000'>"+mes.msg+"</font>");
				}else{
					$("#buName_notice").html("<font  name='dui'></font>");
				}
			},"json")
		}
		
	})
	$("#buPwd").blur(function(){
		var userval=$("#buPwd").val();
		if(userval==""){
			$("#buPwd_notice").html("<font color='#FF0000'>不能为空</font>");
		}else{
			$("#buPwd_notice").html("<font  name='dui'></font>");
		}
		
	})
	$("#buPhone").blur(function(){
		var str=/^1[3|4|5|7|8][0-9]{9}$/;
		var userval=$("#buPhone").val();
		if(userval==""){
			$("#buPhone_notice").html("<font color='#FF0000'>不能为空</font>");
		}else if(!str.test(userval)){
			$("#buPhone_notice").html("<font >请输入正确的格式</font>");
		}else{
			$("#buPhone_notice").html("<font  name='dui'></font>");
		}
		
	})
	$("#companyAddress").blur(function(){
		var pwdval=$("#companyAddress").val();
		if(pwdval==""){
			$("#companyAddress_notice").html("<font color='#FF0000'>不能为空</font>");
		}else{
			$("#companyAddress_notice").html("<font  name='dui'></font>");
		}
	})
	
	
	$("#login").click(function(){
		check_register();
	})
	
	

})
</script>

</body>
</html>